﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.Practices.Unity;
using Lilium.Web.Mvc;
using System.Web.Mvc;

namespace Lilium.Web.Mvc
{
	public class UnityWorkflowFactory: IEntityWorkflowFactory
	{
		public UnityWorkflowFactory(IUnityContainer сontainer)
		{
			if (сontainer == null) throw new ArgumentNullException("сontainer");

			m_Container = сontainer;
		}

		#region IEntityWorkflowFactory Members

		public TWorkflow GetWorkflow<TWorkflow>(EntityController controller)
		{
			Container.RegisterInstance(controller);
			return Container.Resolve<TWorkflow>();
		}

		#endregion

		#region private IUnityContainer Container

		private readonly IUnityContainer m_Container;

		private IUnityContainer Container
		{
			//[System.Diagnostics.DebuggerNonUserCodeAttribute]
			get
			{
				return m_Container;
			}
		}

		#endregion
	}
}
